﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DaInterFace;
using DaInterFace.PDA;

namespace P03
{
    public class A06 : IPDAChild
    {
        public void Code(IPDA handler, CodeResult CR, PDACodeUser user, String parameter)
        {
            P02A04 P = (P02A04)handler.SerialApi.Deserialize(typeof(P02A04), parameter, CR.SerialType);

            try
            {
                SqlParameter[] sps = new SqlParameter[1];
                sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
                sps[0].Value = P.FID;

                String sql = "Select A.FID FROM KEW_SalesInfo A  WHERE A.FNOTE2='' and A.FID=@FID";
                Recordset rs = handler.Data.ExeProcedure(P.AccountNo, sql, sps);
                if (rs.Enable)
                {
                    if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
                    {
                        CR.Result = EnumResult.Error;
                        CR.Message = "袋装信息不存在";
                    }

                    CR.Result = EnumResult.Normal;
                    CR.Content = "";
                    handler.Message(MessageType.Note, String.Format("操作员{0}对单据{1}进行了补袋信息查询", user.UserName, P.FID));
                }
                else
                {
                    CR.Result = EnumResult.Error;
                    CR.Message = "数据库错误";
                }
            }
            catch (Exception ex)
            {
                CR.Result = EnumResult.Error;
                CR.Message = ex.Message;
                handler.Message(MessageType.Error, String.Format("发生错误:{0}", ex.Message));
            }
        }
    }

    public class P02A06
    {
        public string FID;
        public string AccountNo;
    }
}
